package org.example.hellomp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.hellomp.entity.User;
import org.example.hellomp.mapper.UserMapper;
import org.example.hellomp.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class test2 {
    @Autowired

    UserMapper userMapper;
    @Autowired
    UserService userService;

    @Test
    public void test1(){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("name", "Tom");
        List<User> users = userMapper.selectList(queryWrapper);
        System.out.println(users);
    }
    @Test
    public void test2(){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("age");
        List<User> users = userMapper.selectList(queryWrapper);
        System.out.println(users);
    }

    @Test
    public void test3(){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
//        queryWrapper.ge("age",20);
//        queryWrapper.le("age",30);
        queryWrapper.between("age",20,30);
        List<User> users = userMapper.selectList(queryWrapper);
        System.out.println(users);
    }
    @Test
    public void test4(){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("email","baomidou.com").and(wrapper->wrapper.lt("age",20).or().gt("age",30));

        List<User> users = userMapper.selectList(queryWrapper);
        System.out.println(users);
    }
}
